
        function onload(Cesium) {
            var viewer = new Cesium.Viewer('cesiumContainer',{
            imageryProvider: new Cesium.BingMapsImageryProvider({
                url : 'https://dev.virtualearth.net',
                mapStyle : Cesium.BingMapsStyle.AERIAL
            })

            });
            var scene = viewer.scene;
            var widget = viewer.cesiumWidget;
            try{
                var promise = scene.open('http://221.2.244.68:10107/iserver/services/3D-dawangshice/rest/realspace');
                Cesium.when(promise,function(layer){
                    var camera = scene.camera;
                    camera.flyCircleLoop = true;
                    //var center = new Cesium.Cartesian3(0,0,0);
                    // scene.camera.setView({
                    //     destination: Cesium.Cartesian3.fromDegrees(663550.000000000000000, 5328136.000000000000000, 100)
                    // })
                },function(e){
                    if (widget._showRenderLoopErrors) {
                        var title = '加载SCP失败，请检查网络连接状态或者url地址是否正确？';
                        widget.showErrorPanel(title, undefined, e);
                    }
                });
            }
            catch(e){
                if (widget._showRenderLoopErrors) {
                    var title = '渲染时发生错误，已停止渲染。';
                    widget.showErrorPanel(title, undefined, e);
                }
            }
             viewer.imageryLayers.addImageryProvider(new Cesium.WebMapTileServiceImageryProvider({
                url: "http://t0.tianditu.com/cia_w/wmts?service=wmts&request=GetTile&version=1.0.0&LAYER=cia&tileMatrixSet=w&TileMatrix={TileMatrix}&TileRow={TileRow}&TileCol={TileCol}&style=default.jpg",
                layer: "tdtAnnoLayer",
                style: "default",
                format: "image/jpeg",
                tileMatrixSetID: "GoogleMapsCompatible",
                show: false
            }));
           viewer._cesiumWidget._creditContainer.style.display="none";  
        
            var handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
                //设置鼠标左键单击回调事件
            handler.setInputAction(function(e) {
                //首先移除之前添加的点
                viewer.entities.removeAll();
                //获取点击位置笛卡尔坐标
                var position = scene.pickPosition(e.position);
                
                
                //将笛卡尔坐标转化为经纬度坐标
                var cartographic = Cesium.Cartographic.fromCartesian(position);
                var longitude = Cesium.Math.toDegrees(cartographic.longitude);
                var latitude = Cesium.Math.toDegrees(cartographic.latitude);
                var height = cartographic.height;
                if(height < 0) {
                    height = 0;
                }
                var positionX={
                    x:longitude,
                    y:latitude,
                    z:height +2,
                    type:$("#mapbound2").val(),
                    url:$("#mapbound1").val(),
                }
                $("#mapbound").val(JSON.stringify(positionX))
                //在点击位置添加对应点
                viewer.entities.add(new Cesium.Entity({
                    point : new Cesium.PointGraphics({
                        color : new Cesium.Color(1, 1, 0,0),
                        pixelSize : 10,
                        outlineColor : new Cesium.Color(0, 1, 1)
                    }),
                    position : Cesium.Cartesian3.fromDegrees(longitude, latitude , height +2),
                    billboard : {
                                 image : $("#mapbound1").val(),
                                scale : 0.2
                            }
                }));
                $("#mapPopup1").hide();
            }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
            $("#mapForm_Show1").click(function(){
                viewer.entities.removeAll();
                $("#mapPopup1").show();
                if($("#mapbound").val()){
                    console.log($("#mapbound").val())
                    // var pinBuilder = new Cesium.PinBuilder();
                    // var questionPin = viewer.entities.add({
                    //     name : 'Question mark',
                    //     position : Cesium.Cartesian3.fromDegrees(118.52352609853354,36.97802526761681,3.5819516593152425),
                    //     billboard : {
                    //         image : pinBuilder.fromText('测试12', Cesium.Color.BLACK, 60).toDataURL(),
                    //         verticalOrigin : Cesium.VerticalOrigin.BOTTOM
                    //     }
                    // });
                    // Cesium.when.all([questionPin], function(pins){
                    //     viewer.zoomTo(pins);
                    // });
                     var dai=JSON.parse($("#mapbound").val())
                     
                        var questionPin = viewer.entities.add({
                            id:'viewer',
                            name : '',
                            position : Cesium.Cartesian3.fromDegrees(dai.x,dai.y,dai.z),
                            billboard : {
                                     image : dai.url,
                                    scale : 1,
                                    verticalOrigin : Cesium.VerticalOrigin.BOTTOM
                                } 
                        });
                    Cesium.when.all([questionPin], function(pins){
                        viewer.zoomTo(pins);
                    });
                }else{
                    var promise = scene.open('http://221.2.244.68:10107/iserver/services/3D-dawangshice/rest/realspace');
                    Cesium.when(promise,function(layer){
                        var camera = scene.camera;
                        camera.flyCircleLoop = true;
                        var center = new Cesium.Cartesian3(0,0,0);
                        scene.camera.setView({
                            destination: Cesium.Cartesian3.fromDegrees(118.52330223413105, 36.97919219762995, 2)
                        })
                    });
                }
               
                
        })
            $("#Popup_Close12").click(function(){
                $("#mapPopup1").hide();
            })
        }
